/*
 * File:   Utils.c
 * Author: aravelomanantsoa@gmail.com
 */

#include "cJSON.h"
#include <stdio.h>
#include <libpcan.h>

void printJSONErrorMsg(char * msg) {
	cJSON *root = cJSON_CreateObject();
	/* success = FALSE */
	cJSON_AddFalseToObject(root, "success");
	/* add message */
	cJSON_AddStringToObject(root, "msg", msg);

	printf(cJSON_Print(root));
}

/* LSN: Low Significant Number
 MSN: Most Significant Number */
int byteArray2int(BYTE LSN, BYTE MSN) {
	int low = 0, most = 0;
	low = LSN;
	most = MSN;
	most <<= 8;
	return low + most;
}
